/*
 * CustomerManager.java 2012-8-23
 * Copyright(c) 20012-2015 by covidien
 * ALL Rights Reserved.
 */
package com.mvc.base.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.mvc.base.model.Customer;
import com.mvc.framework.dao.HibernateIdUtils;
import com.mvc.framework.model.Auditable;

@Service
public class CustomerManager extends BaseCompanyManager<Customer, Integer> {

	public void save(Customer entity) {
		if (null == entity.getObjectId()) {
			entity.setObjectId(HibernateIdUtils.getUnCacheCustomizeId(getHibernateTemplate().getSessionFactory(), "customerId"));
		}
		super.save(entity);
	}

	public List<Customer> getAll() {
		Customer example = new Customer();
		example.setRecStatus(Auditable.REC_STATUS_VALID);
		return getHibernateTemplate().findByExample(example);
	}
}
